// sharing/pages/user/restart/restart.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
	  var that = this;
	  app.getShareData(function(res){that.setData({cfg: res.data})});
  },

  restart: function () {
	  wx.login({
		success: function (res) {
			app.util.request({
				url: 'entry/wxapp/openid',
				data: { code: res.code, m: 'junsion_wifinav'},
				cachetime: 0,
				success: function (res) {
				  wx.getUserInfo({
					success: function (wxInfo) {
						var info = JSON.parse(wxInfo.rawData);
						app.util.request({
							url: 'entry/wxapp/updateUser',
							data: { openid: res.data, avatar: info.avatarUrl, nickname: info.nickName, gender: info.gender, m: 'junsion_wifinav'},
							cachetime: 0,
							success: function (res) {
								wx.showToast({title: '重新授权成功', icon: 'success'});
							},
							fail: function(){
								wx.showToast({title: '重新授权失败', icon: 'none'});
							}
						});
					}
				  });
				}
			});
		},
	});
  },
  onShareAppMessage: function () {
	  return {
	      title: this.data.cfg.indexShare,
	      path: '/sharing/pages/index/index',
	      success: function(res) {
	        // 转发成功
	      },
	      fail: function(res) {
	        // 转发失败
	      }
	    }
  }
})